package com.szeldon.declatest.declaration.reader.settings;

import java.util.Map;

import com.szeldon.declatest.declaration.reader.exceptions.BadSettingsException;
import com.szeldon.declatest.declaration.settings.JmsSettingsPartDeclaration;
import com.szeldon.declatest.declaration.settings.SettingsDeclaration;

/**
 * Plugin for reading JMS-specific settings.
 * 
 * @author szeldon
 * 
 */
public class JMSSettingsReaderPlugin implements ISettingsReaderPlugin {

    public static final String JMS_SERVICE_SETTINGS_NAME = "JMS";

    public static final String JMS_USERNAME_ATTRIBUTE = "username";
    public static final String JMS_PASSWORD_ATTRIBUTE = "password";
    public static final String JMS_DESTINATION_TYPE_ATTRIBUTE = "destinationType";
    public static final String JMS_DESTINATION_NAME_ATTRIBUTE = "destinationName";
    public static final String JMS_ACTIVITY_TYPE = "activityType";
    public static final String JMS_TIMEOUT = "timeout";

    @Override
    public String getSupportedServiceName() {
        return JMS_SERVICE_SETTINGS_NAME;
    }

    @Override
    public SettingsDeclaration createSettingsDeclaration(String id, String description, Map<String, String> settingsMap)
            throws BadSettingsException {
        
        JmsSettingsPartDeclaration jmsSettings = new JmsSettingsPartDeclaration(id, description,
                settingsMap.get(JMS_USERNAME_ATTRIBUTE), settingsMap.get(JMS_PASSWORD_ATTRIBUTE),
                settingsMap.get(JMS_DESTINATION_TYPE_ATTRIBUTE), settingsMap.get(JMS_DESTINATION_NAME_ATTRIBUTE),
                settingsMap.get(JMS_ACTIVITY_TYPE), settingsMap.get(JMS_TIMEOUT));

        return jmsSettings;

    }
}
